<template>
    <div>
        <Header-Two></Header-Two>
        <div class="allMiddle">
            <div class="middleCenter">
                <div class="homeT">
                    <a-icon type="home"/>
                    <span>首页</span><span>/</span><span>视频详情</span>
                </div>
                <div class="detailMidd">
                    <div class="pigLeft">
                        <img :src="list.bannerFileUrlPc" alt="">
                    </div>
                    <div class="worldRht">
                        <p>{{list.courseTitle}}</p>
                        <p>累计<span>{{list.subSectionNum}}</span>人学习
                            &nbsp;&nbsp;<a-rate :default-value="2.5" allow-half/>
                        </p>
                        <div v-if="list.isFree==1" class="freeCourse">
                            <p>免费</p>
                            <p class="watch">立即观看</p>
                        </div>
                        <div v-else class="moneyCourse">
                            <span>￥{{list.payPrice}}</span>
                            <del>￥{{list.coursePrice}}</del>
                            <p class="freeTop">{{list.discountDesc}}</p>
                            <button>立即购买</button>
                            <button type="primary" @click="openNotification(list.courseId)">加入购物车</button>
                        </div>
                        <div class="loveCollection"  @click="success" v-if="this.$store.state.changColorLove">
                            <a-icon type="heart" style="font-size: 20px"/>
                            <span>收藏</span>
                        </div>
                        <div class="deleLove"  @click="showConfirm" v-else>
                            <a-icon type="heart" style="font-size: 20px"/>
                            <span>收藏</span>
                        </div>
                    </div>
                </div>
                <div class="whiteBlank"></div>
                <!--目录tab页列表组件-->
                <Course-Detail-Tab></Course-Detail-Tab>
                <div class="whiteBlank"></div>
            </div>

        </div>
    </div>
</template>

<script>
    import {courseDetail} from "../api/api";
    import CourseDetailTab from "./CourseDetailTab";
    import HeaderTwo from "./HeaderTwo";

    export default {
        name: "CourseDetail.vue",
        data() {
            return {
                list: [],
                str:this.$store.state["cart/dataReturn"]
            }
        },
        methods:{

            success() {
                this.$message.success('收藏成功');
                this.$store.commit("changLove",false)
                console.log(this.$store.state.changColorLove)
            },

            // addCart(mm){
            //     this.$store.dispatch("cart/addCartList",mm)
            // },

            showConfirm() {


                this.$confirm({
                    title: '确定要取消收藏么？',


                onOk() {
                    console.log('确定');
                },
                onCancel() {
                    console.log('取消');


                },
            class: 'test'
            })
                this.$store.commit("changLove",true)
            },
        //   提示弹出框
            openNotification(mm) {
                console.log()
                this.$store.dispatch("cart/addCartList",mm)


            },
        },
        components: {
            CourseDetailTab,
            HeaderTwo
        },

        created() {

            courseDetail(this.$route.query.courseId).then(res => {
                console.log(res)
                this.list = res.data;
            });
        }
    }
</script>

<style scoped lang="less">
    button:hover{
        cursor: pointer;
    }
    .allMiddle {
        min-height: calc(100vh - 336px);
        background-color: #F4F4F4;

        .middleCenter {
            width: 1200px;
            margin: 0px auto;

            /*background-color: #ffffff;*/

            .homeT {
                height: 46px;
                line-height: 46px;
                background-color: #F4F4F4;
                margin: 0px auto;
                color: rgba(0, 0, 0, .45);

                span {
                    margin: 0px 4px;
                }
            }
        }

        .detailMidd {
            width: 1200px;
            margin: 0px auto;
            height: 310px;
            background-color: #ffffff;
            display: flex;
            justify-content: space-between;
            align-items: center;

            .pigLeft {
                width: 389px;
                height: 220px;
                padding-left: 20px;

                img {
                    width: 330px;
                    height: 220px;
                }
            }

            .worldRht {
                width: calc(100% - 389px);
                height: 220px;
                position: relative;
                padding-left: 10px;
                position: relative;

                .watch {
                    width: 160px;
                    height: 45px;
                    background-color: #04D08E;
                    font-size: 18px !important;
                    color: #FFFFFF !important;
                    position: absolute;
                    bottom: -18px;
                    text-align: center;
                    line-height: 45px;
                }
                .watch:hover {
                    cursor: pointer;
                }

                p:nth-of-type(1) {
                    font-size: 24px;
                }

                p:nth-of-type(2) {
                    font-size: 14px;
                    color: #999;
                }

                .freeCourse {
                    color: #00CF8C;
                    font-size: 24px;
                }
                .loveCollection {
                    width: 110px;
                    height: 30px;
                    border: 1px solid #999;
                    position: absolute;
                    top: 30px;
                    right: 30px;
                    display: flex;
                    justify-content: space-around;
                    padding: 0px 18px;
                    align-items: center;
                    color: #999;
                    font-size: 16px;
                }
                .loveCollection:hover {
                    cursor: pointer;
                }
                .deleLove {
                    width: 110px;
                    height: 30px;
                    border: 1px solid red;
                    position: absolute;
                    top: 30px;
                    right: 30px;
                    display: flex;
                    justify-content: space-around;
                    padding: 0px 18px;
                    align-items: center;
                    color: red;
                    font-size: 16px;
                }
                .deleLove:hover {
                    cursor: pointer;
                }
            }
        }
    }

    .freeTop {
        width: 66px;
        height: 20px;
        font-size: 12px !important;
        margin-right: 16px;
        text-align: center;
        color: #fa8c16;
        line-height: 20px;
        background-color: #FFF7E6;
        border: 1px solid #ffd591;
        margin: 10px 0px;
    }

    .moneyCourse {
        span {
            font-size: 24px;
            margin-right: 10px;
            font-weight: bold;
        }

        del {
            color: rgb(255, 79, 35);
        }

        button {
            outline: none;
            border: none;
            width: 160px;
            height: 45px;
        }

        button:nth-of-type(1) {
            background-color: #FF8000;
            margin-right: 20px;
            color: #FFFFFF;
            font-size: 18px;
        }

        button:nth-of-type(2) {
            background-color: #00CF8C;
            color: #FFFFFF;
            font-size: 18px;
        }
    }

    .whiteBlank {
        height: 20px;
        background-color: #F4F4F4;
    }
</style>